package user

import (
	"context"
	"errors"
	"gitee.com/gopher2011/go-zero-gva/internal/svc"
	"github.com/tal-tech/go-zero/core/logx"
)

type User struct {
	logx.Logger
	Ctx    context.Context
	SvcCtx *svc.ServiceContext
}

func NewUser(ctx context.Context, svcCtx *svc.ServiceContext) *User {
	return &User{
		Logger: logx.WithContext(ctx),
		Ctx:    ctx,
		SvcCtx: svcCtx,
	}
}

func (l *User)FindUserByUuid(uuid string) (error, *svc.SysUser) {
	var user svc.SysUser
	if err := l.SvcCtx.DB.Where("uuid = ?",uuid).First(&user).Error;err !=nil {
		return errors.New("用户不存在"), &user
	}
	return nil, &user
}